package com.gmail.bloim.serg.testrunner;

import org.apache.commons.lang3.time.DateUtils;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * User: Администратор
 * Date: 26.04.13
 * Time: 2:36
 */
public class TestTimeRegistrator implements TestExecutionFlowRegistrator {
    private final Map<Test, Long> started = new HashMap<Test, Long>();
    private final Map<Test, Long> registations = new HashMap<Test, Long>();

    @Override
    public void onTestStart(Test test) {
        started.put(test, new Date().getTime());
    }

    @Override
    public void onTestFinish(Test test) {
        long now = new Date().getTime();
        Long start = started.get(test);
        registations.put(test, now - start);
    }

    public long getTestExecutionTime(Test test) {
        return registations.get(test);
    }
}
